﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
public partial class zoushitu_dlt_dlt_hqzh : System.Web.UI.Page
{
    protected List<Model.LotteryAnnouncement> arlist = null;
    protected string[] SSQList = null;
    protected string SSQblue = null;
    protected int jinqiCount = 0;
    protected DataTable dtPaperList = new DataTable();

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            jinqiCount = 30;
            bindData(30);
        }
    }

    protected int jishuCount = 0;
    protected int oushuCount = 0;
    protected int liangqu1Count = 0;
    protected int liangqu2Cuont = 0;
    protected int sanqu1Count = 0;
    protected int sanqu2Count = 0;
    protected int sanqu3Count = 0;
    protected int siqu1Count = 0;
    protected int siqu2Count = 0;
    protected int siqu3Count = 0;
    protected int siqu4Count = 0;
    protected void bindData(int maxValue)
    {

        arlist = BLL.LotteryAnnouncement.getDatas(maxValue,2);

        if (arlist != null)
        {
            dtPaperList.Columns.Add("Id", typeof(int));
            dtPaperList.Columns.Add("Hezhi", typeof(string));
            dtPaperList.Columns.Add("JiShu", typeof(string));
            dtPaperList.Columns.Add("Oushu", typeof(string));

            dtPaperList.Columns.Add("LiangQu1", typeof(string));
            dtPaperList.Columns.Add("LiangQu2", typeof(string));
            dtPaperList.Columns.Add("SanQu1", typeof(string));
            dtPaperList.Columns.Add("SanQu2", typeof(string));
            dtPaperList.Columns.Add("SanQu3", typeof(string));
            dtPaperList.Columns.Add("SiQu1", typeof(string));
            dtPaperList.Columns.Add("SiQu2", typeof(string));
            dtPaperList.Columns.Add("SiQu3", typeof(string));
            dtPaperList.Columns.Add("SiQu4", typeof(string));

            for (int i = 0; i < arlist.Count; i++)
            {
                DataRow newRow = dtPaperList.NewRow();
                newRow["Id"] = i + 1;
                string[] blueBall = arlist[i].LotteryNo.Split('+')[1].Split(',');
                int hezhi = 0;
                int jishu = 0;
                int oushu = 0;
                int liangqu1 = 0;
                int liangqu2 = 0;
                int sanqu1 = 0;
                int sanqu2 = 0;
                int sanqu3 = 0;
                int siqu1 = 0;
                int siqu2 = 0;
                int siqu3 = 0;
                int siqu4 = 0;

                for (int m = 0; m < blueBall.Length; m++)
                {
                    #region
                    //计算条形图中每个数的个数篮球
                    int blueBallCode = int.Parse(blueBall[m]);
                    bindTiaoxing(0, blueBallCode);
                    hezhi += blueBallCode;//和值
                    if (blueBallCode % 2 == 0)//判断奇偶个数
                    {
                        oushu = oushu + 1;
                    }
                    else
                    {
                        jishu = jishu + 1;
                    }
                    if (blueBallCode > 0 && blueBallCode < 7)
                    {
                        liangqu1 = liangqu1 + 1;
                    }
                    if (blueBallCode > 6 && blueBallCode < 13)
                    {
                        liangqu2 = liangqu2 + 1;
                    }
                    if (blueBallCode > 0 && blueBallCode < 5)
                    {
                        sanqu1 = sanqu1 + 1;
                    }
                    if (blueBallCode > 4 && blueBallCode < 9)
                    {
                        sanqu2 = sanqu2 + 1;
                    }
                    if (blueBallCode > 8 && blueBallCode < 13)
                    {
                        sanqu3 = sanqu3 + 1;
                    }
                    if (blueBallCode > 0 && blueBallCode < 4)
                    {
                        siqu1 = siqu1 + 1;
                    }
                    if (blueBallCode > 3 && blueBallCode < 7)
                    {
                        siqu2 = siqu2 + 1;
                    }
                    if (blueBallCode > 6 && blueBallCode < 10)
                    {
                        siqu3 = siqu3 + 1;
                    }
                    if (blueBallCode > 9 && blueBallCode < 13)
                    {
                        siqu4 = siqu4 + 1;
                    }
                    #endregion
                }
                jishuCount += jishu;
                oushuCount += oushu;
                liangqu1Count += liangqu1;
                liangqu2Cuont += liangqu2;
                sanqu1Count += sanqu1;
                sanqu2Count += sanqu2;
                sanqu3Count += sanqu3;
                siqu1Count += siqu1;
                siqu2Count += siqu2;
                siqu3Count += siqu3;
                siqu4Count += siqu4;
                newRow["Hezhi"] = hezhi;
                newRow["JiShu"] = jishu;
                newRow["Oushu"] = oushu;
                newRow["LiangQu1"] = liangqu1;
                newRow["LiangQu2"] = liangqu2;
                newRow["SanQu1"] = sanqu1;
                newRow["SanQu2"] = sanqu2;
                newRow["SanQu3"] = sanqu3;
                newRow["SiQu1"] = siqu1;
                newRow["SiQu2"] = siqu2;
                newRow["SiQu3"] = siqu3;
                newRow["SiQu4"] = siqu4;
                dtPaperList.Rows.Add(newRow);
            }
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
       
        jinqiCount = int.Parse(DropDownList1.SelectedValue);
        bindData(int.Parse(DropDownList1.SelectedValue));
    }
    protected int[] TiaoxingDT = new int[12];
    /// <summary>
    /// 计算红篮球的出现个数
    /// </summary>
    /// <param name="type">0 篮球</param>
    /// <param name="data">对应球的号码</param>
    protected void bindTiaoxing(int type, int data)
    {
        for (int i = 0; i < 12; i++)
        {
            if (type == 0)
            {
                if (data == (i + 1))
                {
                    TiaoxingDT[i] += 1;
                }
            }
            //if (type == 1)
            //{
            //    if (data == (i + 1 - 35))
            //    {
            //        TiaoxingDT[i] += 1;
            //    }
            //}
        }
    }
}